﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Provausio.Common.Objects
{
    public abstract class BusinessOperation<TInput, TOuput>
        where TOuput : new()
    {
        public abstract TOuput Run(TInput input);

        protected TOuput ValidateAndRun(TInput input, bool validate, Func<TOuput> operation)
        {
            var result = new TOuput();
            var validationResults = new List<object>();
            if (validate)
            {
                //TODO validation
            }

            //if validation is good
            result = operation();

            return result;
        }

        private static bool DefaultValidation(TInput input)
        {
            //TODO implement contract validation as default validator
            return true;
        }
    }
}
